import Vuex from 'vuex'
import event from '../net/capitalListCont'

Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    userxzqhdm: '',
    xzqh: '',
    sTime: '',
    eTime: '',
    gridHead: [
        { name: 'xzqhmc', value: '行政区划'},
        { name: 'lhmj', value: '绿化面积'},
        { name: 'lhyhf', value: '绿化年养护费'},
        { name: 'jnds', value: '节能灯数'},
        { name: 'zmyhf', value: '照明养护费'},
        { name: 'gcs', value: '公测数'},
        { name: 'gcyhf', value: '公厕养护费'},
        { name: 'wsl', value: '污水量'},
        { name: 'wsyhf', value: '污水养护费'},
        { name: 'ljl', value: '垃圾量'},
        { name: 'ljyhf', value: '垃圾养护费'},
        { name: 'ysgs', value: '太阳能浴室数'},
        { name: 'ysyhf', value: '太阳能浴室养护费'}
    ],
    gridData: []
  },
  mutations: {
    changeUserxzqhdm (state, value) {
      state.userxzqhdm = value
    },
    changeXzqh (state, value) {
      state.xzqh = value
    },
    changeStime (state, value) {
      state.sTime = value
    },
    changeEtime (state, value) {
      state.eTime = value
    },
    changeGridHead (state, value) {
      state.gridHead = value
    },
    changeGridData (state, value) {
      state.gridData = value
    }
  },
  actions: {
    getDatalist ({commit, state}, vm) {
      // vm.$notice.alert(state)
      vm.$notice.loading.show()
      event.getTJ8({
        quyxzqhdm: state.xzqh,
        T0SDATE: state.sTime,
        T0EDATE: state.eTime
      }).then(res => {
        vm.$notice.alert(res)
        commit('changeGridData', res)
        vm.$nextTick(() => {
          vm.$notice.loading.hide()
        })
      })
    }
  }
})
